﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../../common/jsp/taglibs.jsp"%>
<!-- 
    Copyright (C)  2011  chen wei hua.
    Permission is granted to copy, distribute and/or modify this document
    under the terms of the GNU Free Documentation License, Version 2.0
    or any later version published by the Free Software Foundation;
    with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
    A copy of the license is included in the section entitled "GNU Free Documentation License".
 -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>出货</TITLE>
<META content="text/html; charset=utf-8" http-equiv=Content-Type>
<%@ include file="../../common/jsp/config.jsp"%>
<%@ include file="../../common/jsp/validate.jsp"%>
<%@ include file="../../common/jsp/autocomplete.jsp"%>
<script type="text/javascript" src="common/js/calendar/WdatePicker.js" ></script>
<script type="text/javascript">

function computerAmount(id) {
	var productNamesCount = <s:property value="order.orderDetails.size" />;
	var number = $("#productNums-" + id).val();
	var prices = $("#productPrices-" + id).html();
	var totleValue = number * prices;
	$("#productAmounts-" + id).val(totleValue.toFixed(2));
	var totleNumber = 0;
	for (var i = 0; i < productNamesCount; i++) {
		totleNumber += parseFloat($("#productAmounts-" + i).val());
	}
	$("#order_totleAmount").val(totleNumber.toFixed(2));
}

$(document).ready(function() {
	$("#saveDeliveryOrder").validate();
	$("#order_logisticsName").autocomplete("queryLogisticsNames.action", {
		width: 200,
		max: 10,
		autoFill: false,
		dataType: "json",
		parse: function(data) {
			var parsed = [];
			var rows = data.logisticsList;
			for (var i=0; i < rows.length; i++) {
				var row = rows[i];
				if (row) {
					parsed[parsed.length] = {
						data: row,
						value: row[0],
						result: row[1]//最终选择后显示的内容
					};
				}
			}
			return parsed;
		},
		formatItem: function(row, i, max) {
			return row[1];//列表中显示的值
		}
	}).result(function(e, row) {
		//alert(row[0]);//最终选择的ID
		$(e.target).next().val(row[0]);
	});
});
</script>
</HEAD>
<BODY>
    <div class="subnav" align="left">
           <table width="100%" border="0" cellspacing="0" cellpadding="0">
		  <tr>
			<td width="100%" align="left" height="31">&nbsp;<img src="common/images/title-pk.gif" border="0"  align="absmiddle"/>&nbsp;<span class="subnavtxt1">出货管理</span>
			&nbsp;<img src="common/images/leftico2.gif" border="0"  align="absmiddle"/>&nbsp;<span class="subnavtxt2">出货</span></td>
		  </tr>
		</table>
      </div>
	<s:actionerror cssStyle="color:red"/>
     <s:form action="saveDeliveryOrder">
     <s:hidden name="orderId" value="%{order.id}" />
     <div class="main_1">
       <table width="99%" border="0" cellpadding="10" cellspacing="1" bgcolor="#D3DEEF">
         <tr>
           <td align="left" class="Blue14" bgcolor="#FAFAFA" colspan="4">成品交运单信息</td>
         </tr>
         <tr>
		    <td width="20%" bgcolor="#FAFAFA" align="right"><strong>单号</strong></td>
		    <td width="30%" bgcolor="#FAFAFA">
		      <s:textfield name="order.orderNo" size="20" cssClass="{required:true,maxlength:20}"/>
	          <span class="red-text1">*</span>
			</td>
		    <td width="20%" bgcolor="#FAFAFA" align="right"><strong>发货日期</strong></td>
		    <td width="30%" bgcolor="#FAFAFA">
	          <s:textfield name="order.deliveryDate" size="10" value="%{#detail.finishDate}" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" readonly="true" cssClass="{required:true}"/>
	          <span class="red-text1">*</span>
	        </td>
		 </tr>
		<tr>
	      <td bgcolor="#FAFAFA" align="right"><strong>客户名称</strong></td>
	      <td bgcolor="#FAFAFA"><s:property value="order.customName"/></td>
	      <td bgcolor="#FAFAFA" align="right"><strong>总金额</strong></td>
	      <td bgcolor="#FAFAFA">
	        <s:textfield id="order_totleAmount" name="order.totleAmount" readonly="true" size="10" cssClass="inputdisabled"/>
	      </td>
		</tr>
		<tr>
	      <td bgcolor="#FAFAFA" align="right"><strong>收货人</strong></td>
	      <td bgcolor="#FAFAFA">
			<s:textfield name="order.receivers" size="10" cssClass="{required:true,maxlength:10}"/>
			<span class="red-text1">*</span>
		  </td>
	      <td bgcolor="#FAFAFA" align="right"><strong>联系电话</strong></td>
	      <td bgcolor="#FAFAFA">
			<s:textfield name="order.telephone" size="20" cssClass="{required:true,maxlength:20}"/>
			<span class="red-text1">*</span>
		  </td>
		</tr>
		<tr>
	      <td bgcolor="#FAFAFA" align="right"><strong>收货地址</strong></td>
	      <td bgcolor="#FAFAFA" colspan="3">
			<s:textfield name="order.address" size="90" cssClass="{required:true,maxlength:120}"/>
			<span class="red-text1">*</span>
		  </td>
		</tr>
		<tr>
	      <td bgcolor="#FAFAFA" align="right"><strong>运输方式</strong></td>
	      <td bgcolor="#FAFAFA">
	      	  <s:select name="order.logisticsType"
	          		list="logisticsTypeList"
	          		listKey="id"
	          		listValue="value"
	          		headerKey="-1"
	          		headerValue="-请选择-"
	          		cssClass="{selected:true}" />
	        <span class="red-text1">*</span>
	      </td>
	      <td bgcolor="#FAFAFA" align="right"><strong>物流公司</strong></td>
	      <td bgcolor="#FAFAFA">
			<s:textfield id="order_logisticsName" name="order.logisticsName" size="30" />
			<s:hidden id="order_logisticsId" name="order.logisticsId" />
	      </td>
		</tr>
		<tr>
	      <td bgcolor="#FAFAFA" align="right"><strong>总毛重(kg)</strong></td>
	      <td bgcolor="#FAFAFA">
			<s:textfield name="order.totleWeight" size="10" cssClass="{required:true,maxlength:10,number:true}"/>
	        <span class="red-text1">*</span>
		  </td>
	      <td bgcolor="#FAFAFA" align="right"><strong>总体积(m3)</strong></td>
	      <td bgcolor="#FAFAFA">
			<s:textfield name="order.totleVolume" size="10" cssClass="{required:true,maxlength:10,number:true}"/>
			<span class="red-text1">*</span>
	      </td>
		</tr>
  </table>
</div>
     <div class="clear"></div>
	 <div class="main_scroll">
       <table width="1000px" cellpadding="0" cellspacing="1" border="0" class="ksglxx2a">
        <tr class="ksglxx2bg">
          <th width="50px" >大分类</th>
          <th width="60px" >中分类</th>
          <th width="95px" >名称</th>
          <th width="180px" >型号</th>
          <th width="180px" >其他</th>
		  <th width="50px">单位</th>
		  <th width="65px">发货数量</th>
		  <th width="65px" align="center">包装数量(箱)</th>
		  <th width="65px" align="left">价格</th>
		  <th width="65px" align="left">金额</th>
		  <th align="left">备注</th>
		</tr>
		<s:iterator value="order.orderDetails" id="detail" status="st">
          <s:if test="#st.Odd">
            <tr class="odd">
          </s:if>
          <s:else>
            <tr class="even">
          </s:else>
          <td><s:property value="#detail.productRootCategory" /></td>
          <td><s:property value="#detail.productCategory" /></td>
          <td><s:property value="#detail.productName" /></td>
          <td><s:property value="#detail.productType" /></td>
          <td><s:property value="#detail.productSku" />
              <s:hidden name="detailIds" value="%{#detail.id}" /></td>
          <td><s:property value="#detail.unit" /></td>
          <td><s:property value="#detail.number" /></td>
          <td><s:property value="#detail.packageNumber" /></td>
          <td><s:property value="#detail.price" /></td>
          <td><s:property value="#detail.amount" /></td>
          <td><s:textfield id="deliveryInfos-%{#st.index}" name="deliveryInfos" value="%{#detail.deliveryInfo}" size="20" cssClass="{maxlength:20}"/></td>
	    </tr>
	    </s:iterator>
       </table>
      </div>
     <div class="clear"></div>
	 <div class="main_1">
		<table width="98%" border="0" cellpadding="5" cellspacing="0" class="gr-text1">
		   <tr>
			 <td width="50%" align="right"><s:submit value="保存" cssClass="input1" /></td>
			 <td width="50%" align="left"><input type="button" value="关闭" class="input1" onclick='javascript:window.location.href="deliveryOrderList.action"' /></td>
		   </tr>
	   </table>
	</div>
	</s:form>
	<div class="clear"></div>
</BODY></HTML>
